﻿package com.wandian.controller
{
	import com.wandian.data.GameData;
	import com.wandian.model.AccountProxy;
	import com.wandian.model.UserInfoProxy;
	import com.wandian.model.vo.PlayerVo;
	import com.wandian.model.vo.RoomVo;
	import com.wandian.view.mediator.GameMessageMediator;
	import com.wandian.view.mediator.GameRoomMediator;
	import com.wandian.view.mediator.MaskGameMediator;
	import com.wandian.view.mediator.account.AccountMediator;
	
	import flash.display.MovieClip;
	
	import org.puremvc.as3.interfaces.*;
	import org.puremvc.as3.patterns.command.*;

    public class GameMessageCommand extends SimpleCommand
    {
        private var _global:GameData;
        private var _mcPanel:MovieClip;

        public function GameMessageCommand()
        {
            this._global = GameData.getInstance();
            return;
        }

        override public function execute(notification:INotification) : void
        {
            var _loc_3:int = 0;
            var _loc_4:String = null;
            var _loc_5:int = 0;
            var _loc_6:Array = null;
            super.execute(notification);
            var uerinfoProxy:UserInfoProxy = facade.retrieveProxy(UserInfoProxy.NAME) as UserInfoProxy;
            switch(notification.getName())
            {
                case CLZNoticeName.SHOW_GAME_MESSAGE_PANEL:
                {
                    _loc_3 = notification.getBody() as int;
                    _loc_4 = notification.getType();
                    _loc_5 = 0;
                    if (_loc_4 != "")
                    {
                    }
                    if (_loc_4 != null)
                    {
                        _loc_6 = _loc_4.split("-");
                        _loc_5 = _loc_6[1];
                        _loc_3 = _loc_6[0];
                    }
                    this.showMessagePanel(_loc_3, _loc_5);
                    break;
                }
                case CLZNoticeName.MESSAGE_SYSTEM_REQ:
                {
                    uerinfoProxy.requestGameMessageList(notification.getBody() as Boolean);
                    break;
                }
                default:
                {
                    break;
                }
            }
            return;
        }

        private function showMessagePanel(param1:int, param2:int) : void
        {
            if (!this._mcPanel)
            {
                this._mcPanel = GameData.getMovieClip("GameMessagePanel");
            }
            if (!Texas.I._mcWindosView.contains(this._mcPanel))
            {
                Texas.I._mcWindosView.addChildTo(this._mcPanel);
            }
            Texas.I._mcWindosView.centerXY(this._mcPanel);
            facade.registerMediator(new GameMessageMediator(this._mcPanel, param1, param2));
            return;
        }

    }
}
